/* 引入less */
/* 重置样式 */
require('../css/commCss/normalize.css')
/* 重置样式补充 */
require('../css/commCss/reset.css')
/* 公共样式 */
require('../css/commCss/property.css')
/* 公共属性 */
require('../css/commCss/basic.less')
/* 字体图标 */
require('../fonts/iconfont.css')
/* 当前页面 */
require('../css/myself.less')


/**
 * 定义获取数据
 */

const util = require('../util/util')

/* 引入weui */
require('weui');
const weui = require('weui.js');

/* 引入axios */
const axios = require('axios');

/***
 * 0. 底部公共样式
 */
util.utilBottomNav('myself', 'app-myself')


document.addEventListener('DOMContentLoaded', function () {
    /* 获取变量 */
    let userId = localStorage.getItem('userId');
    let imgurl = document.querySelector('#imgurl');
    let nickname = document.querySelector('#nickname');
    let sign = document.querySelector('#sign');
    let dynamicCount = document.querySelector('#dynamicCount');
    let times = document.querySelector('#times');
    let calorie = document.querySelector('#calorie');
    let loginOut = document.querySelector('#loginOut');

    /* 渲染数据 */
    axios.get('http://139.9.177.51:8099/users/mysportsBadge?userId=' + userId, {

    }).then(function (res) {
        //console.log(res);

        //头像
        if (res.data.data.user.imgurl) {
            imgurl.src = res.data.data.user.imgurl
        }
        //用户名
        nickname.textContent = res.data.data.user.nickname

        //个性签名
        if (res.data.data.user.sign) {
            sign.textContent = res.data.data.user.sign
        }

        //动态
        dynamicCount.textContent = res.data.data.dynamicCount + '条'

        //运动时间
        times.textContent = res.data.data.sports.times

        //卡路里
        calorie.textContent = res.data.data.sports.calorie

    })

    /* 退出登录 */
    loginOut.addEventListener('click', function () {
        weui.confirm('你确定要退出登录吗?', function () {
            location.href = './register.html'
        })
    })

    /* 点击顶部头像模块进入信息修改界面 */
    document.querySelector('#myselfUser').addEventListener('click', function () {
        location.href = './personalData.html'
    })
})